package com.sxy;

import com.sxy.dao.BookDao;
import com.sxy.dao.impl.BookDaoImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import javax.sql.DataSource;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public class App {
    public static void main(String[] args) {
        /**
         * 加载类路径下的配置文件
         */
        //获取ioc容器
        ApplicationContext c = new ClassPathXmlApplicationContext("applicationContext.xml");

//        DataSource dataSource = (DataSource) c.getBean("dataSource");
//
//        System.out.println(dataSource);
        //获取bean的三种方式
        BookDao bookDao = (BookDao) c.getBean("bookDao");
//        BookDao bookDao1 = c.getBean("bookDao", BookDao.class);
//        BookDao bookDao1 = c.getBean(BookDao.class); 使用按类型查找容器中只能有一个类型的bean
        bookDao.save();
        /**
         * 从文件系统下加载配置文件
         */
//        ApplicationContext c1 = new FileSystemXmlApplicationContext("D:\\idea_WorkSpace\\SSM-JAVA\\spring-datasource\\src\\main\\resources\\applicationContext.xml");
    }
}
